<template>
  <div>
    <div id="app">
      <table
        class="mars"
        cellspacing="1"
        cellpadding="0"
        width="100%"
        border="0"
      >
        <tbody>
          <tr bgcolor="#fba661" height="30">
            <td width="7%"><div align="center">编号ID</div></td>
            <td width="15%"><div align="center">分类名称</div></td>
            <td width="18%"><div align="center">申报开始时间</div></td>
            <td width="14%"><div align="center">申报结束时间</div></td>
            <td width="20%"><div align="center">评审专家编号</div></td>
            <td width="13%"><div align="center">修改</div></td>
            <td width="13%"><div align="center">删除</div></td>
          </tr>
          <tr
            bgcolor="#e4f1fe"
            v-for="(projectCategory, index) in projectCategoryList"
            :key="index"
          >
            <td bgcolor="#f3f3f3"><div align="center">1</div></td>
            <td bgcolor="#f3f3f3">
              <div align="center">{{ projectCategory.categoryname }}</div>
            </td>
            <td bgcolor="#f3f3f3">
              <div align="center">{{ projectCategory.repStartTime }}</div>
            </td>
            <td bgcolor="#f3f3f3">
              <div align="center">{{ projectCategory.repStopTime }}</div>
            </td>
            <td bgcolor="#f3f3f3">
              <div align="center">{{ projectCategory.expertid }}</div>
            </td>
            <td bgcolor="#f3f3f3">
              <div align="center">
                <button @click="gotoUpdateProject(index)">修改</button>
              </div>
            </td>
            <td bgcolor="#f3f3f3">
              <div align="center">
                <button @click="deleteProject(projectCategory.categoryid)">
                  删除
                </button>
              </div>
            </td>
          </tr>
          <tr bgcolor="#e4f1fe">
            <td height="20" colspan="7" valign="bottom" bgcolor="#FFFFFF">
              <div align="center">
                <router-link to="/declare/admin/addProject">新增加类别</router-link>
              </div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>

    <div id="container">
      <div id="footer">
        <p>
          <a href="http://www.ascenttech.com.cn/" target="_blank"
            >版权所有：北京亚思晟商务科技有限公司
            &copy;2004-2008|京ICP备05005681</a
          >
        </p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data:function() {
return {
      projectCategory:{
        categoryid:'',
        expertid:'',
        categoryname:'',
        repStartTime:'',
        repStopTime:'',
        expStartTime:'',
        expStopTime:''

      },
      projectCategoryList:''

    };
},
    mounted()
    {
    this.getAllProjectCategory();
    },
    methods:{
      getAllProjectCategory:function ()
      {
        this.$axios.get(
                "http://localhost:8080/api/admin/showAllProjectCategorys"
        )
                .then((resp)=>{
                  this.projectCategoryList=resp.data.data;
                  console.log(resp.data.code+" "+resp.data.msg);
                })
      },
      gotoUpdateProject:function (index)
      {
        localStorage.setItem("project",JSON.stringify(this.projectCategoryList[index]))
        location.href="/declare/admin/UpdateProject";
      },
      deleteProject:function (categoryid)
      {
        this.$axios({
          method: 'post',
          url: 'http://localhost:8080/api/admin/deleteProject?id='+categoryid,
        })
                .then((resp)=>
                {
                  console.log(resp.code+" "+resp.msg);
                  location.href="/declare/admin/showProjectCategorys";
                })
      }

    }
};
</script>

<style>
</style>